package svc

import (
	{{.configImport}}

	"go-weixin/app/usercenter/rpc/userrpcclient"
	"go-weixin/common/apiserver"
	"go-weixin/common/rpcserver"
	"github.com/zeromicro/go-zero/zrpc"
)

type ServiceContext struct {
	Config {{.config}}
	{{.middleware}}
	ApiMDLE *apiserver.Middleware
	UserRpc userrpcclient.UserCenter
}

func NewServiceContext(c {{.config}}) *ServiceContext {
	rpcMDLE := rpcserver.NewMiddleware()
	userRpc := userrpcclient.NewUserRpcClient(zrpc.MustNewClient(zrpc.RpcClientConf{Endpoints: c.UserRpc.Endpoints, NonBlock: c.UserRpc.NonBlock}, zrpc.WithUnaryClientInterceptor(rpcMDLE.ClientRpcMiddleware)))
	return &ServiceContext{
		Config: c,
		ApiMDLE: apiserver.NewApiMiddleware(userRpc),
		UserRpc: userRpc,
		{{.middlewareAssignment}}
	}
}
